package com.team.ai.service;

import cn.hutool.core.date.DateTime;
import com.qiniu.qvs.RecordManager;
import com.team.ai.entity.ResultEntity;
import com.team.ai.entity.User;
import com.team.ai.mapper.RcordingMapper;
import com.team.ai.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

@Service
public class RecordingService {
    @Resource
    RcordingMapper rcordingMapper;

    @Resource
    UserMapper userMapper;
    public String insert(int userId, int svId,String title,String video){
        try{
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date now = DateTime.now();
            String dateStr = sdf.format(now);
            Date date = sdf.parse(dateStr);
            System.out.println(now);
            return ResultEntity.success(rcordingMapper.insert(userId, svId,title,video,date)) ;
        }catch (Exception e){
            e.printStackTrace();
            return  ResultEntity.fail(-10005);
        }
    }
    public String selectList(int userId){
        try{
            return ResultEntity.success(rcordingMapper.selectList(userId)) ;
        }catch (Exception e){
            e.printStackTrace();
            return  ResultEntity.fail(-10005);
        }
    }

}
